package day18.tarena.Thred;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DaoJiShi extends Thread  implements ActionListener{
	private int time = 7200;
	JLabel jl = new JLabel("  2:00:00  ");
	//JTextField jtf = new JTextField(20);
	int t = 0;
	String jbt =  "开始";
	public void actionPerformed(ActionEvent e) {
			this.start();
	}
	
	public void run() {
		for (int i = time; i >= 0; i--) {
			int h = i / 3600;		//get 2
			int m = i % 3600 / 60;    //get 0/60m  --->   60s
			int s = i % 60;          //get
			String str = h + ":" + m + ":" + s;
			jl.setText(str);
			try {
				Thread.sleep(1000);
				t++;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	
	public DaoJiShi(){
    	JFrame jf = new JFrame("倒计时");
    	jf.setLayout(new FlowLayout());
    	JButton jb  = new JButton("倒计时开始");
    	jb.addActionListener(this);
   // 	jf.add(jtf);
    	jf.add(jb);
    	jf.add(jl);
		jf.setLocation(400,400);
		jf.pack();
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	}
	public static void main(String[] args) {
		new DaoJiShi();
	}
}
